package com.wx.chapter10.abstract_;

import com.wx.javacode.poly_.polyarr_.Teacher;

abstract public class Template {
    public abstract void job();//抽象方法，通过子类去实现

    public void calculateTime() {
        //计算运行时间
        long start = System.currentTimeMillis();
        job();//动态绑定机制
        long end = System.currentTimeMillis();
        System.out.println("任务执行时间 " + (end - start));
    }
}

class AA extends Template {

    @Override
    public void job() {
        long num = 0;
        for (int i = 0; i < 800000; i++) {
            num += i;
        }
    }
}

class BB extends Template {

    @Override
    public void job() {
        long num = 2;
        for (int i = 0; i < 200000000; i++) {
            num *= i;
        }
    }
}